#pragma once

#include <string>
#include <vector>
#include <memory>
#include <utility>
#include <ctime>
#include <mutex>
#include <opencv2/opencv.hpp>

#include "common/model_config.h"
#include "horizon/base/hb_predictor.h"
#include "horizon/hbmodel_manager.h"


namespace ai {

class HBDetPredictor : public HBPredictor {
public:
  HBDetPredictor(HBPackPredictor* model, HBModelManager* mng, LogInfo *lg);
  ~HBDetPredictor(){}
  

  int PostProcess_yolov5(std::vector<BaseInfo*>& det_infos);
  int PostProcess_yolov8(stream::ImageBlob* blob, std::vector<BaseInfo*>& det_infos);

private:

  int RunDet(stream::ImageBlob* blob, std::vector<BaseInfo*>& det_infos);
  int GenerateMeshGrid();
  float sigmoid(float x);



private:
  void ParseTensor(float* out_data, int layer, 
    std::vector<cv::Rect>& boxs, std::vector<float>& scores, std::vector<int>& labels,
    std::vector<int> ori_shape, std::vector<int> feteature_shape, ModelConfig* cfg);
  int get_tensor_hw(hbDNNTensor* tensor, int *height, int *width);

private:

  int cur_block;
  std::vector<float> MeshGrid;
  int HeadNum;
  int TopK = 50;
};

}  // namespace hb
